package club.ljwang.service;

import club.ljwang.dao.LogMapper;
import club.ljwang.entity.PageResult;
import club.ljwang.entity.QueryPageBean;
import club.ljwang.pojo.CheckItem;
import club.ljwang.pojo.SysLog;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description:
 * @author: ming
 * @date: 2020/3/9-14:58
 * @Version: 1.0.0
 */
@Service(interfaceClass = LogService.class)
@Transactional
public class LogServiceImpl implements  LogService{
    @Autowired
    private LogMapper logMapper;

    @Override
    public void recordLog(SysLog sysLog) {
        logMapper.recordLog(sysLog);
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        //1.告诉Mybatis我们要分页
        Page page = PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        //2.写一个跟分页毫无关系的sql
        List<SysLog> sysLogs = logMapper.findPage(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),sysLogs);


    }
}
